﻿Imports System.Data
Imports VSModel
Imports Cls_Common
Imports SecurityService

Partial Class Control_MSDS_Section01View
    Inherits System.Web.UI.UserControl

	Private Shared ReadOnly log As log4net.ILog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType)
#Region "EVENT FOR CONTROL"

	Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
		If Not IsPostBack Then
			Me.EnableViewState = False
			Translate()
			Dim script As ScriptManager = ScriptManager.GetCurrent(Me.Page)
			If Not script Is Nothing AndAlso script.IsInAsyncPostBack Then
				ScriptManager.RegisterStartupScript(Me.Page, Me.Page.GetType, "duyjs", "ajaxJquery()", True)
			Else
				Me.Page.ClientScript.RegisterStartupScript(Me.Page.GetType(), "duyjs", String.Concat("Sys.Application.add_load(function(){", "ajaxJquery()", "});"), True)
			End If
			If Not Request.QueryString("Id").ToString.Equals("0") Then
				hidMSDSID.Value = Request.QueryString("Id")
			End If
			CheckData()
		End If
	End Sub
	Protected Sub Translate()
		lblSection01Title.Text = getTranslate("lblSection01Title", Session("LanguageId"), lblSection01Title.Text)
		lbSection01lChemicaleName.Text = getTranslate("lbSection01lChemicaleName", Session("LanguageId"), lbSection01lChemicaleName.Text)
		lbSection01lSynonyms.Text = getTranslate("lbSection01lSynonyms", Session("LanguageId"), lbSection01lSynonyms.Text)
		lbSection01lTradeName.Text = getTranslate("lbSection01lTradeName", Session("LanguageId"), lbSection01lTradeName.Text)
		lbSection01Mname.Text = getTranslate("lbSection01Mname", Session("LanguageId"), lbSection01Mname.Text)
		lbSection01Sname.Text = getTranslate("lbSection01Sname", Session("LanguageId"), lbSection01Sname.Text)
	End Sub

#End Region
#Region "PRIAVTE SUB AND FUNCTION"
	Sub CheckData()
		Using data As New VSEntities
			Dim LanguageId = Session("LanguageId").ToString()
			Dim p = (From q In data.MSDSSection01
					 Where q.LanguageId = LanguageId And q.MSDSId = hidMSDSID.Value
					 ).FirstOrDefault()
			If Not p Is Nothing Then
				txtS101.Text = p.S101
				txtS102.Text = p.S102
				txtS103.Text = p.S103

				txtS108.Text = p.S108
				'' show info nhà sản xuất và địa chỉ
				txtS201.Text = p.S201 & " - " & p.S203

				'' show info nhà cung cấp và địa chỉ
				txtS301.Text = p.S301 & " - " & p.S303
				
			End If
			Translate()
		End Using
	End Sub
#End Region

End Class
